<?php
require_once('lzu_op_fns.php');
$sno = $_POST['sno'];
$passwd = $_POST['passwd'];
$passwd2 = $_POST['passwd2'];
$tel = $_POST['tel'];
if(session_status() == PHP_SESSION_NONE) {
    session_start();
}
try {
    if (!filled_out($_POST)) {
        throw new Exception("请填写完整", 1);
    }
    if (strlen($tel) != 11) {
        throw new Exception("手机号码长度不正确", 1);
    }
    if ($passwd != $passwd2) {
        throw new Exception("两次输入的密码不一致", 1);
    }
    if ((strlen($passwd) < 6) || (strlen($passwd) > 16)) {
        throw new Exception("密码长度不正确，请输入6至16位密码", 1);
    }
    register($sno, $passwd, $tel);
    $_SESSION['valid_user'] = $sno;
    do_html_header('注册成功！');
    echo "<a href='check.php'>点击跳转至首页</a>";
    do_html_footer();
} catch (Exception $e) {
    do_html_header('错误：');
    echo $e->getMessage();
    do_html_footer();
    exit;
}
?>